﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Schema;

namespace MetalSoda
{
    /// <summary>
    /// Specifies how Service Broker validates the message body.
    /// </summary>
    public abstract class Validation
    {
        /// <summary>
        /// Specifies that no validation is performed. The message body can contain data, or it can be NULL.
        /// </summary>
        public static readonly Validation None = new StaticValidation();

        /// <summary>
        /// Specifies that the message body must be NULL.
        /// </summary>
        public static readonly Validation Empty = new StaticValidation();

        /// <summary>
        /// Specifies that the message body must contain well-formed XML.
        /// </summary>
        public static readonly Validation WellFormedXml = new StaticValidation();

        /// <summary>
        /// Specifies that the message body must contain XML that complies with a schema in the specified schema collection.
        /// </summary>
        /// <param name="schemaCollectionName">Name of the XML schema collection to be registered in the SQL Server database.</param>
        /// <param name="xmlSchema">XML schema</param>
        /// <returns></returns>
        public static Validation ValidXml(string schemaCollectionName, System.Xml.Schema.XmlSchema xmlSchema) { return new XmlSchemaValidation(schemaCollectionName, xmlSchema); }

        /// <summary>
        /// Specifies that the message body must contain XML that complies with a schema of the speciied CLR type.
        /// </summary>
        /// <param name="schemaCollectionName">Name of the XML schema collection to be registered in the SQL Server database.</param>
        /// <param name="type">CLR type defining the XML schema</param>
        /// <returns></returns>
        public static Validation ValidXml(string schemaCollectionName, Type type) { throw new NotImplementedException(); }             
    }

    sealed class StaticValidation : Validation { }


    sealed class XmlSchemaValidation : Validation
    {
        public readonly System.Xml.Schema.XmlSchema XmlSchema;

        public readonly string SchemaCollectionName;

        internal XmlSchemaValidation(string schemaCollectionName, System.Xml.Schema.XmlSchema xmlSchema) 
        {
            this.SchemaCollectionName = schemaCollectionName;
            this.XmlSchema = xmlSchema;
        }

    }
}
